package klk.shop.z.kev.artikel.eigenschaften;


public class Dimension implements Comparable<Dimension> {

    // statische Felder ---------------------------------------------------------------------------
    // statische Methoden -------------------------------------------------------------------------
    // --------------------------------------------------------------------------------------------


    // Instanzfelder ------------------------------------------------------------------------------
    private int x = 0,
            y = 0;
    private String einheit = "";
    // getter fuer eigene Felder -------------------------------------------------------------------

    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }

    public String getEinheit() {
        return einheit;
    }
    // setter fuer eigene Felder -------------------------------------------------------------------

    public void setX(int x) {
        this.x = x;
    }

    public void setY(int y) {
        this.y = y;
    }

    public void setEinheit(String einheit) {
        this.einheit = einheit;
    }
    // --------------------------------------------------------------------------------------------

    // Klassenspezifishes -------------------------------------------------------------------------
    public String toHtml() {
        return "<html><table border=1 style='font-family:monospace;" +
                    "th{" +
                    "text-align:left;" +
                        "background-color:#99ddff;" +
                        "width:150px;" +
                    "}" +
                    "td{" +
                        "background-color:#ddeeff;" +
                        "width:300px;" +
                    "}'>" +
                    "" +//toTeilHtml() +
                "</table></html>";
    }


    @Override
    public String toString() {
        return String.format("%d x %d %s", x, y, einheit);
    }

    @Override
    public int compareTo(Dimension o) {
        return x * y - o.getX() * o.getY();
    }
    // --------------------------------------------------------------------------------------------

    // Konstruktoren ------------------------------------------------------------------------------
    public Dimension(int x, int y, String einheit) {
        super();
        this.x = x;
        this.y = y;
        this.einheit = einheit;
    }
    // --------------------------------------------------------------------------------------------
}
